﻿using Microsoft.Extensions.DependencyInjection;

namespace K9Nano.Updater.Client;

public static class IocHelper
{
    public static IServiceProvider ServiceProvider { get; private set; }

    public static void ConfigureServices(Action<IServiceCollection> configure)
    {
        var services = new ServiceCollection();

        configure(services);

        ServiceProvider = services.BuildServiceProvider();
    }

    public static T GetService<T>() where T : notnull => ServiceProvider.GetRequiredService<T>();
}